﻿using BMSQ.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BMSQ.Admin.GoodsType2
{
    public partial class Add : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGoodsType1();
            }
        }

        private void BindGoodsType1()
        {
            BindDrowDownList(ddlGoodsType1, new BLL.Goods_Type1().GetModelList(""), "GT1_Name", "GT1_ID", true);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
           if (this.txtGT2_Name.Text.Trim().Length == 0)
            {
                strErr += "GT2_Name不能为空！\\n";
            }
            if (this.ddlGoodsType1.SelectedIndex<1)
            {
                strErr += "GT1_ID不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string GT2_ID = DBParameter.GetGuid();
            string GT2_Name = this.txtGT2_Name.Text;
            string GT1_ID = ddlGoodsType1.SelectedValue;

            Model.Goods_Type2 model = new Model.Goods_Type2();
            model.GT2_ID = GT2_ID;
            model.GT2_Name = GT2_Name;
            model.GT1_ID = GT1_ID;

            BLL.Goods_Type2 bll = new BLL.Goods_Type2();
            bll.Add(model);
            MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}